package com.dataprocess.samples.vehicle.controller;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisPool;
import redis.clients.jedis.JedisPoolConfig;

@RefreshScope
@Configuration
public class RedisConfig {

    @Value("${redis.redisserver:redis}")
    private String redisServer;

    @Value("${redis.redisport:6379}")
    private int redisPort;


    @Bean
    public Jedis jedis() {
        JedisPoolConfig poolConfig = new JedisPoolConfig();
        JedisPool jedisPool = new JedisPool(poolConfig, redisServer, redisPort, 0);
        return jedisPool.getResource();
    }
}
